#include "gameMath.h"

float InvSqrt(float x)
{
	float xhalf = 0.5f*x;
	int i = *(int*)&x; // get bits for floating VALUE 
	i = 0x5f375a86- (i>>1); // gives initial guess y0
	x = *(float*)&i; // convert bits BACK to float
	x = x*(1.5f-xhalf*x*x); // Newton step, repeating increases accuracy
	return x;
}  

int al_atan(int x, int y)
{
	al_fixed binary_angle;

	binary_angle = 32;

	binary_angle = al_fixatan2(al_itofix(x), al_itofix(y));

	binary_angle = al_fixtoi(binary_angle);
	int i = 0;
	i = (int)binary_angle/256.0*360.0;
	return i;
}

float angleToRad(int angle)
{
	return (float)angle/180*ALLEGRO_PI;
}
